class code1 {
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0;
        int right = 0;
        int sum = 0;
        int ret = Integer.MAX_VALUE;
        while(right < nums.length) {
            //进窗口
            sum += nums[right];
            //出窗口
            while(sum >= target) {
                ret = Math.min(right-left+1,ret);
                sum -= nums[left++];
            }
            right++;
        }
        return ret==Integer.MAX_VALUE?0:ret;
    }
}